<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            display: flex;
            /* width: 500px; */
            /* align-items: center; */
            /* margin: 0 auto; */
        }
        #one{
            width: 100px;
        }
        #two{
            width: 100px;
        }
        #sum{
            width: 40px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div id="box">
        <input id="one" type="text" name="" id="">
        +
        <input id="two" type="text" name="" id="">
        =
        <div id="sum">?</div>
        <input type="button" value="求和">
    </div>
</body>
<script>
    window.onload = function(){
        var inp = document.getElementsByTagName("input")
        for(var i = 0 ; i < 2 ; i++){
            inp[i].onkeyup = function(){
                this.value = this.value.replace(/[^\d|","]/,"")
            }
            inp[2].onclick = function(){
                var one = document.querySelector('#one').value
                var two = document.querySelector('#two').value
                var oSum = document.querySelector('#sum')
                var sum = 0
                sum += parseInt(one) + parseInt(two)
                oSum.innerHTML = sum
            }
        }
    }
</script>
</html>